package com.biscuit.page.basicservice.remote.api;

import com.alibaba.fastjson.JSON;
import com.biscuit.common.base.BaseResponse;
import com.biscuit.page.basicservice.api.IFileRemote;
import com.biscuit.page.basicservice.api.model.request.file.FileImageUploadAReq;
import com.biscuit.page.basicservice.api.model.response.file.FileImageUploadAResp;
import com.biscuit.page.basicservice.service.FileService;
import com.biscuit.page.basicservice.utils.BaseResponseUtil;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author mazihao
 * @createTime 2024/4/1 9:31
 */
@RestController
public class FileRemoteImpl implements IFileRemote {

    @Resource
    private FileService service;

    @Override
    public BaseResponse<FileImageUploadAResp> imageUpload(MultipartFile multipartFile, String reqJson) {
        FileImageUploadAReq req = JSON.parseObject(reqJson, FileImageUploadAReq.class);
        return BaseResponseUtil.success(this.service.imageUpload(multipartFile, req));
    }
}
